/**
 * 
 */
package sob.netcode.refstyle;

/**
 * @author blackcore
 * @date 2013-11-15
 * @describe
 */
public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		testBadSwap();
		
		testTrickySwap();
	}

	static void testBadSwap() {
		BadSwap swap = new BadSwap();

		int a = 1, b = 10;
		swap.Swap(a, b);
		System.out.println(String.format("main:\ta%d,b%d", a, b));
		System.out.println();

		Integer A = 1, B = 10;
		swap.Swap(A, B);
		System.out.println(String.format("main:\tA%d,B%d", A, B));
	}

	static void testTrickySwap() {
		System.out.println("SwapError交换后！");
		Point p1 = new Point(1, 1);
		Point p2 = new Point(2, 2);
		System.out.println("p1\tX: " + p1.getA() + " Y: " + p1.getB());
		System.out.println("p2\tX: " + p2.getA() + " Y: " + p2.getB());
		new TrickySwap().SwapError(p1, p2);
		System.out.println("p1\tX: " + p1.getA() + " Y: " + p1.getB());
		System.out.println("p2\tX: " + p2.getA() + " Y: " + p2.getB());
		
		System.out.println("\r\nSwapRight交换后！");
		Point p3 = new Point(3, 3);
		Point p4 = new Point(4, 4);
		System.out.println("p3\tX: " + p3.getA() + " Y: " + p3.getB());
		System.out.println("p4\tX: " + p4.getA() + " Y: " + p4.getB());
		new TrickySwap().SwapRight(p3, p4);
		System.out.println("p3\tX: " + p3.getA() + " Y: " + p3.getB());
		System.out.println("p4\tX: " + p4.getA() + " Y: " + p4.getB());
	}

}
